#include "DFRobot_K10Box.h"


DFRobot_K10Box box; 

void setup()
{
  Serial.begin(115200);
  box.begin();
  box.initQMI8658C();
  Serial.println("begin");
}

void loop()
{
  
  Serial.print("soundVolume = ");
  Serial.println(box.getSoundVolume(),HEX);
  Serial.print("KnobValue = ");
  Serial.println(box.getKnobValue(),HEX);
  Serial.print("IRValue = ");
  Serial.println(box.getIRValue(),HEX);
  Serial.print("SR04 = ");
  Serial.println(box.getSR04Value());

  Serial.print("LinePatrolThreshold 0 = ");
  Serial.println(box.getLinePatrolThreshold(0));
  Serial.print("LinePatrolThreshold 1 = ");
  Serial.println(box.getLinePatrolThreshold(1));
  Serial.print("LinePatrolThreshold 2 = ");
  Serial.println(box.getLinePatrolThreshold(2));
  Serial.print("LinePatrolThreshold 3 = ");
  Serial.println(box.getLinePatrolThreshold(3));
  Serial.print("LinePatrolThreshold 4 = ");
  Serial.println(box.getLinePatrolThreshold(4));

  Serial.print("getLinePatrolValue 0 = ");
  Serial.println(box.getLinePatrolValue(0));
  Serial.print("getLinePatrolValue 1 = ");
  Serial.println(box.getLinePatrolValue(1));
  Serial.print("getLinePatrolValue 2 = ");
  Serial.println(box.getLinePatrolValue(2));
  Serial.print("getLinePatrolValue 3 = ");
  Serial.println(box.getLinePatrolValue(3));
  Serial.print("getLinePatrolValue 4 = ");
  Serial.println(box.getLinePatrolValue(4));

  Serial.print("getLinePatrolStatusAll = ");
  Serial.println(box.getLinePatrolStatusAll(),BIN);
  
  box.getQMI8658xyz();
  Serial.print("AccX = ");
  Serial.print(box.getAccelerometerXmg());
  Serial.print("mg,");
  Serial.print(box.getAccelerometerXms2());
  Serial.println("m/s2");

  Serial.print("AccY = ");
  Serial.print(box.getAccelerometerYmg());
  Serial.print("mg,");
  Serial.print(box.getAccelerometerYms2());
  Serial.println("m/s2");

  Serial.print("AccZ = ");
  Serial.print(box.getAccelerometerZmg());
  Serial.print("mg,");
  Serial.print(box.getAccelerometerZms2());
  Serial.println("m/s2");

  Serial.print("GyroX = ");
  Serial.print(box.getGyroscopeXdps());
  Serial.print("dps,");
  Serial.print(box.getGyroscopeXrads());
  Serial.println("rad/s");

  Serial.print("GyroY = ");
  Serial.print(box.getGyroscopeYdps());
  Serial.print("dps,");
  Serial.print(box.getGyroscopeYrads());
  Serial.println("rad/s");

  Serial.print("GyroZ = ");
  Serial.print(box.getGyroscopeZdps());
  Serial.print("dps,");
  Serial.print(box.getGyroscopeZrads());
  Serial.println("rad/s");
  delay(500);

  //设置M1电机正转
  box.setMotor1Run(0,255);
  //设置M2电机反转
  box.setMotor2Run(1,255);


  //设置蜂鸣器的频率为2000HZ
  box.setBuzzer(2000);
  delay(1000);
  box.setBuzzer(0);


  //设置LED灯亮度，范围（0~255）
  box.red_analog(255);
  box.yellow_analog(255);
  box.green_analog(255);
  delay(500);

  //控制LED亮
  box.red_digital(1);
  box.yellow_digital(1);
  box.green_digital(1);
  delay(500);
  //控制LED灭
  box.red_digital(0);
  box.yellow_digital(0);
  box.green_digital(0);
  delay(500);

}